package cn.schoolwow.util.module.check.instance.flow;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

import java.util.Objects;

public class CheckInstanceFieldValueFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        Object actualValue = flowContext.getData("actualValue");
        Object expectValue = flowContext.getData("expectValue");
        String message = (String) flowContext.checkData("message");

        if(!Objects.equals(actualValue, expectValue)){
            throw new IllegalArgumentException(message+"的值不符合期望!"
                    + "实际值:"+actualValue
                    + ",期望值:"+expectValue
            );
        }
    }

    @Override
    public String name() {
        return "实例-检查列表值是否有重复值";
    }
}
